package com.seek.util;

import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.collections.MapUtils;

/**
 * Created by weh on 2017/7/11.
 */
public class RelationUtil {

  private static Map<String, String> regMap = new LinkedHashMap<>();

  static {
    initRelation();
  }

  public static void initRelation() {

    regMap.put("爷爷", ".*爷.*|.*祖父.*");
    regMap.put("奶奶", ".*奶.*|.*祖母.*");
    regMap.put("外公", ".*外公.*");
    regMap.put("外婆", ".*外婆.*");
    regMap.put("父亲", ".*爸.*|.*父.*");
    regMap.put("母亲", ".*妈.*|.*母.*");
    regMap.put("姑父", ".*姑父.*");
    regMap.put("姑姑", ".*姑.*");
    regMap.put("姨夫", ".*姨夫.*");
    regMap.put("阿姨", ".*姨.*");
    regMap.put("哥哥", ".*哥.*|.*兄.*");
    regMap.put("配偶", ".*老公.*|.*老婆.*|.*太太.*|.*爱人.*|.*夫人.*");
    regMap.put("哥哥", ".*哥.*|.*兄.*");
    regMap.put("弟弟", ".*弟.*");
    regMap.put("姐姐", ".*姐.*|.*姊.*");
    regMap.put("妹妹", ".*妹.*");
    regMap.put("子女", ".*女.*|.*儿.*|.*子.*");
    regMap.put("伯伯", ".*伯.*|.*大爷.*");
    regMap.put("叔叔", ".*叔.*");
    regMap.put("婶婶", ".*婶.*");
    regMap.put("舅妈", ".*舅妈.*");
    regMap.put("舅舅", ".*舅.*");
  }


  public static String getRelation(String name) {
    String relation = "";
    if (MapUtils.isEmpty(regMap)) {
      initRelation();
    }
    for (Map.Entry<String, String> entry : regMap.entrySet()) {
      if (name.matches(entry.getValue())) {
        relation = entry.getKey();
        break;
      }
    }
    return relation;
  }

}
